xlv.obj.fbApi={
	extend:function(){
	},
	implement:function(){
	},
	create:function(tag){
		var div=document.createElement((tag||'div'));
		div.setAttribute('xlvobject','xlv.obj.fbApi');
		return div;			
	},
	properties:{
		appId:'181836915197998',
		fbConnetion:'//connect.facebook.net/en_US/all.js',
		perms:'publish_stream',
		autoLoad:true
	},
	method:{
		construct:function(){
			this.setAttribute('id','fb-root');
			this.$V.read=false;
		},
		initial:function(){
			if(this.$P.autoLoad) this.loadApi();
		},
		loadApi:function(){
			this._loadApi();
		},
		_loadApi:function(){
			window.fbAsyncInit = function(){this._fbAsyncInit();}.bind(this);
			var e = document.createElement('script'); e.async = true;
		    e.src = document.location.protocol +this.$P.fbConnetion;
		    this.appendChild(e);
		},
		_fbAsyncInit:function(){
		    FB.init({appId:this.$P.appId, status: true, cookie: true,xfbml: true});
		    this.$V.read=true;
		    this.fbInitial();
		},
		fbInitial:function(){
		},
		login:function(){
			var opts={};
			if(this.$P.perms)opts.perms=this.$P.perms;
			FB.login(function(resp){this.loginResponse(resp);}.bind(this),opts);
		},
		loginResponse:function(resp){
			this.$V.login=(resp.session)?true:false;
			this.$V.loginResp=resp;
		},
		loginStatus:function(){
			FB.getLoginStatus(function(resp){this.loginStatusResp(resp);}.bind(this));
		},
		loginStatusResp:function(resp){
			this.$V.statusResp=resp;
		},
		queryData:function(){
			 var query = FB.Data.query('select name, uid,email,hometown_location,current_location,birthday from user where uid={0}',this.$V.loginResp.session.uid);
			 query.wait(function(rows){
				 alert('data :'+json2xml(rows[0]));
			 });
		},
		feed:function(){
		},
		styleFor:function(){
		}
	}
};
